#region Using directives.
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Data;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.Design;
using System.Web.UI.Design.WebControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Threading;
using System.Configuration;

#endregion
using BizElements.BusinessLayer;

namespace BizElements.Web
{
    // COMMENTED - UiMessages is used instead.

    //#region Documentation.
    ///// <summary>Reads customized user interface messages for <see cref="SearchProviderBuilder"/> control from a <see cref="ITextSource"/> object.</summary>
    ///// <remarks><para>Values returned from SearchProviderBuilderTextSource objects override values set through SearchProviderBuilder's properties. If a 
    ///// SearchProviderBuilderTextSource property returns null then no override occurs, i.e. a value set through SearchProviderBuilder property or a skin file is used.</para>
    ///// <para>Settings are read from the application's config file as shown in the following example:
    ///// <code>
    ///// <configuration>
    /////     <appSettings>
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodAssembly" value="MyApplication" />
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodClass" value="MyApplication.MyClass"/>
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodName" value="MyApplication.MyClass.GetDefaultTextSource" />
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.DefaultKeyPrefix" value="SearchProviderBuilderTextSource_" />
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureAssembly" value="MyApplication" />
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureClass" value="MyApplication.MyClass"/>
    /////         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureMethodName" value="MyApplication.MyClass.GetUiCulture" />
    /////     </appSettings>
    ///// </configuration>
    ///// </code></para>
    ///// </remarks>
    //#endregion
    //public class SearchProviderBuilderTextSource : ISearchProviderBuilderTextSource
    //{
    //    #region Configuration.

    //    /// <summary>A method which gets default source of captions configured in application configuration file.</summary>
    //    /// <remarks>Settings are read from the application's config file as shown in the following example:
    //    /// <code>
    //    /// <configuration>
    //    ///     <appSettings>
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodAssembly" value="MyApplication" />
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodClass" value="MyApplication.MyClass"/>
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodName" value="MyApplication.MyClass.GetDefaultTextSource" />
    //    ///     </appSettings>
    //    /// </configuration>
    //    /// </code>
    //    /// </remarks>
    //    public static readonly Delegates.Function<ITextSource> GetDefaultTextSource;

    //    /// <summary>Default key prefix for properties/captions retrieved from text source</summary>
    //    /// <remarks>Settings are read from the application's config file as shown in the following example:
    //    /// <code>
    //    /// <configuration>
    //    ///     <appSettings>
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.DefaultKeyPrefix" value="SearchProviderBuilderTextSource_" />
    //    ///     </appSettings>
    //    /// </configuration>
    //    /// </code>
    //    /// </remarks>
    //    public static readonly string DefaultKeyPrefix;

    //    /// <summary>A method which gets a culture used by current user. If not set then <b>Thread.CurrentThread.CurrentUICulture</b> is used.</summary>
    //    /// <remarks>Settings are read from the application's config file as shown in the following example:
    //    /// <code>
    //    /// <configuration>
    //    ///     <appSettings>
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureAssembly" value="MyApplication" />
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureClass" value="MyApplication.MyClass"/>
    //    ///         <add key="BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureMethodName" value="MyApplication.MyClass.GetUiCulture" />
    //    ///     </appSettings>
    //    /// </configuration>
    //    /// </code>
    //    /// </remarks>
    //    public static readonly Delegates.Function<CultureInfo> GetUiCulture;

    //    static SearchProviderBuilderTextSource()
    //    {
    //        DefaultKeyPrefix = ConfigurationManager.AppSettings["BizElements.Web.SearchProviderBuilderTextSource.DefaultKeyPrefix"];

    //        GetDefaultTextSource = ReflectionUtil.TryCreateDelegateFromAppSettings<Delegates.Function<ITextSource>>(
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodAssembly",
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodClass",
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetDefaultTextSourceMethodName");

    //        GetUiCulture = ReflectionUtil.TryCreateDelegateFromAppSettings<Delegates.Function<CultureInfo>>(
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureAssembly",
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureClass",
    //            "BizElements.Web.SearchProviderBuilderTextSource.GetUiCultureMethodName");
    //    }

    //    #endregion

    //    #region Constructors.

    //    /// <summary>Initializes a new instance of the <b>SearchProviderBuilderTextSource</b> class.</summary>
    //    /// <remarks><see cref="TextSource"/> property or <see cref="GetDefaultTextSource"/> delegate must be initialized before <b>SearchProviderBuilderTextSource</b> can be used.</remarks>
    //    public SearchProviderBuilderTextSource()
    //    {
    //        this.keyPrefix = DefaultKeyPrefix;
    //    }

    //    /// <summary>Initializes a new instance of the <b>SearchProviderBuilderTextSource</b> class.</summary>
    //    /// <param name="textSource">The source of captions. <b>null</b> is not allowed.</param>
    //    public SearchProviderBuilderTextSource(ITextSource textSource)
    //    {
    //        if (textSource == null) throw new ArgumentNullException("textSource", "textSource may not be a null reference.");
    //        this.textSource = textSource;
    //        this.keyPrefix = DefaultKeyPrefix;
    //    }

    //    /// <summary>Initializes a new instance of the <b>SearchProviderBuilderTextSource</b> class.</summary>
    //    /// <param name="textSource">The source of captions. <b>null</b> is not allowed.</param>
    //    /// <param name="keyPrefix">Key prefix for properties/captions retrieved from text source.</param>
    //    public SearchProviderBuilderTextSource(ITextSource textSource, string keyPrefix)
    //    {
    //        if (textSource == null) throw new ArgumentNullException("textSource", "textSource may not be a null reference.");
    //        this.textSource = textSource;
    //        this.keyPrefix = keyPrefix;
    //    }

    //    #endregion

    //    #region TextSource.

    //    private string GetProperty(string property)
    //    {
    //        if (this.KeyPrefix != null)
    //            return this.TextSource.GetString(string.Format("{0}{1}", this.KeyPrefix, property), GetCulture());
    //        else
    //            return this.TextSource.GetString(property, GetCulture());
    //    }

    //    private static CultureInfo GetCulture()
    //    {
    //        if (GetUiCulture != null)
    //            return GetUiCulture();
    //        else
    //            return Thread.CurrentThread.CurrentUICulture;
    //    }

    //    ITextSource textSource;

    //    private void EnsureTextSource()
    //    {
    //        if (this.textSource == null)
    //        {
    //            if (GetDefaultTextSource == null)
    //                throw new InvalidOperationException("GetDefaultTextSource delegate is not configured in application's configuration file.");

    //            this.textSource = GetDefaultTextSource();
    //        }
    //    }

    //    /// <summary>Gets or sets source of captions.</summary>
    //    public ITextSource TextSource
    //    {
    //        get
    //        {
    //            EnsureTextSource();
    //            return this.textSource;
    //        }
    //        set
    //        {
    //            if (value == null) throw new ArgumentNullException("value", "value may not be a null reference.");
    //            this.textSource = value;
    //        }
    //    }

    //    string keyPrefix;

    //    /// <summary>Gets or sets key prefix for properties/captions retrieved from text source.</summary>
    //    /// <value>String; default is null.</value>
    //    /// <remarks>If prefix is not set, then it is assumed that property names are used in text source. 
    //    /// For example, if no prefix is defined, then key used for <b>AddWithOrText</b> property would be <b>AddWithOrText</b>.
    //    /// If, for example, key prefix is set to <b>MyView_</b>, then the value is stored under <b>MyView_AddWithOrText</b> key.</remarks>
    //    public string KeyPrefix
    //    {
    //        get { return this.keyPrefix; }
    //        set { this.keyPrefix = value; }
    //    }

    //    #endregion

    //    #region ISearchProviderBuilderTextSource.

    //    /// <summary>Gets or the <b>Text</b> property of the <see cref="IWebCommand"/> which accepts the selected values and sets them into the <see cref="ISearchClient"/> component.</summary>
    //    public string AcceptCommandText
    //    {
    //        get { return GetProperty("AcceptCommandText"); }
    //    }

    //    /// <summary>Gets the <b>Text</b> property of the <see cref="IWebCommand"/> which cancels and closes the search provider/page.</summary>
    //    public string CancelCommandText
    //    {
    //        get { return GetProperty("CancelCommandText"); }
    //    }

    //    #endregion
    //}
}
